home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 1999 February / Macworld (1999-02).dmg / Cinema 4D GO demo / Gumption Plug-ins / Plug-ins / Freeware / DistCalc / DistCalc.cof
Text File  |  1998-03-14  |  2KB  |  101 lines

  1. /*------------------------------------------------------------------------------
  2. *    File name:    DistCalc.cof
  3. *
  4. *    Date        Who            What & Why
  5. *    ===========    ===========    ====================================================
  6. *    1998/03/10    Y.Manabe    • new
  7. *-----------------------------------------------------------------------------*/
  8.  
  9. DistCalc(doc)
  10. {
  11.     var    d = new(SimpleDialog);
  12.     var camera, obj1, obj2, obj3;
  13.     var    cameraName, obj1Name, obj2Name, obj3Name;
  14.     var    cameraPosition, objPosition;
  15.     var    tmpMatrix = new(Matrix);
  16.  
  17.     // Displlay Dialog, and get camera & obj names
  18.     d->SetData(0, "Camera", FIELD_STRING, 0, 0, "Camera");
  19.     d->SetData(1, "Object1", FIELD_STRING, 0, 0, "Object1");
  20.     d->SetData(2, "Object2", FIELD_STRING, 0, 0, "Object2");
  21.     d->SetData(3, "Object3", FIELD_STRING, 0, 0, "Object3");
  22.     d->SetTitle("Dist.Calc.");
  23.     if (d->DoDialog() != TRUE)
  24.     {
  25.         return FALSE;
  26.     } // end if != true
  27.  
  28.     cameraName = d->GetData(0);
  29.     obj1Name = d->GetData(1);
  30.     obj2Name = d->GetData(2);
  31.     obj3Name = d->GetData(3);
  32.  
  33.     camera = doc->FindObject(d->GetData(0));
  34.     obj1 = doc->FindObject(d->GetData(1));
  35.     obj2 = doc->FindObject(d->GetData(2));
  36.     obj3 = doc->FindObject(d->GetData(3));
  37.  
  38.     if (camera == NULL)
  39.     {
  40.         TextDialog(stradd("Can't find ", cameraName),
  41.                     DLG_OK + DLG_ICONEXCLAMATION);
  42.         return TRUE;
  43.     } // end if camera
  44.     else
  45.     {
  46.         camera->GetMg(tmpMatrix);
  47.         cameraPosition = tmpMatrix->MulP(vector(0));
  48.     } // end else
  49.  
  50.     OpenConsole();
  51.  
  52.     if (obj1 != NULL)
  53.     {
  54.         println(stradd("From ", cameraName, " to ", obj1Name));
  55.         obj1->GetMg(tmpMatrix);
  56.         objPosition = tmpMatrix->MulP(vector(0));
  57.         println(vlen(objPosition - cameraPosition));
  58.         println("");
  59.     } // end if obj1
  60.     else
  61.     {
  62.         println(stradd("Can't find ", obj1Name));
  63.         println("");
  64.     } // end else
  65.  
  66.     if (obj2 != NULL)
  67.     {
  68.         println(stradd("From ", cameraName, " to ", obj2Name));
  69.         obj2->GetMg(tmpMatrix);
  70.         objPosition = tmpMatrix->MulP(vector(0));
  71.         println(vlen(objPosition - cameraPosition));
  72.         println("");
  73.     } // end 
  74.     else
  75.     {
  76.         println(stradd("Can't find ", obj2Name));
  77.         println("");
  78.     } // end else
  79.  
  80.     if (obj3 != NULL)
  81.     {
  82.         println(stradd("From ", cameraName, " to ", obj3Name));
  83.         obj3->GetMg(tmpMatrix);
  84.         objPosition = tmpMatrix->MulP(vector(0));
  85.         println(vlen(objPosition - cameraPosition));
  86.         println("");
  87.     } // end 
  88.     else
  89.     {
  90.         println(stradd("Can't find ", obj3Name));
  91.         println("");
  92.     } // end else
  93.  
  94.     return TRUE;
  95. }
  96.  
  97. main()
  98. {
  99.     RegisterMenuHook("DistCalc", "DistCalc");
  100. } // end main()
  101.